package com.ruoyi.teamManagement.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teamManagement.mapper.DocTeamMapper;
import com.ruoyi.teamManagement.domain.DocTeam;
import com.ruoyi.teamManagement.service.IDocTeamService;

/**
 * 签约团队管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@Service
public class DocTeamServiceImpl implements IDocTeamService 
{
    @Autowired
    private DocTeamMapper docTeamMapper;

    /**
     * 查询签约团队管理
     * 
     * @param teamId 签约团队管理主键
     * @return 签约团队管理
     */
    @Override
    public DocTeam selectDocTeamByTeamId(Long teamId)
    {
        return docTeamMapper.selectDocTeamByTeamId(teamId);
    }

    /**
     * 查询签约团队管理列表
     * 
     * @param docTeam 签约团队管理
     * @return 签约团队管理
     */
    @Override
    public List<DocTeam> selectDocTeamList(DocTeam docTeam)
    {
        return docTeamMapper.selectDocTeamList(docTeam);
    }

    /**
     * 新增签约团队管理
     * 
     * @param docTeam 签约团队管理
     * @return 结果
     */
    @Override
    public int insertDocTeam(DocTeam docTeam)
    {
        return docTeamMapper.insertDocTeam(docTeam);
    }

    /**
     * 修改签约团队管理
     * 
     * @param docTeam 签约团队管理
     * @return 结果
     */
    @Override
    public int updateDocTeam(DocTeam docTeam)
    {
        return docTeamMapper.updateDocTeam(docTeam);
    }

    /**
     * 批量删除签约团队管理
     * 
     * @param teamIds 需要删除的签约团队管理主键
     * @return 结果
     */
    @Override
    public int deleteDocTeamByTeamIds(Long[] teamIds)
    {
        return docTeamMapper.deleteDocTeamByTeamIds(teamIds);
    }

    /**
     * 删除签约团队管理信息
     * 
     * @param teamId 签约团队管理主键
     * @return 结果
     */
    @Override
    public int deleteDocTeamByTeamId(Long teamId)
    {
        return docTeamMapper.deleteDocTeamByTeamId(teamId);
    }

    /**
     * 增加团队签约数量
     * 
     * @param teamId 团队ID
     * @return 结果
     */
    @Override
    public int incrementSignedNumber(Long teamId)
    {
        DocTeam team = docTeamMapper.selectDocTeamByTeamId(teamId);
        if (team != null) {
            // 增加签约数量
            team.setSignedNumber(team.getSignedNumber() + 1);
            // 更新团队信息
            return docTeamMapper.updateDocTeam(team);
        }
        return 0; // 团队不存在
    }
}
